package com.yanglei.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.stereotype.Service;

@Service
public class PaymentServiceHystrix {

    public String paymentInfo_ok(String id) {
        return id +"======================ok!";
    }

    @HystrixCommand(fallbackMethod = "fallbackMethod11",commandProperties = {
            @HystrixProperty(name="execution.isolation.thread.timeoutInMilliseconds", value = "5000")
    })
    public String paymentInfo_No(String id) throws InterruptedException {
        Thread.sleep(3000);
        return id + "no_______________ok!";
    }

    /*
    fallback方法的形参要保证一致
     */
    public String fallbackMethod11(String id){
        return "1、本端服务超时，无法运行；2、本段服务异常，无法运行；3、服务宕机，无法运行" +
                "【以上三点，进行服务降级！】";
    }


}
